<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
      <title>Tagged with remote devices - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=remote+devices</link>
      <pubDate>Sun, 08 Aug 2021 18:47:08 +0000</pubDate>
         <description>Tagged with remote devices - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggedremote+devices/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>communicate between two macs in processing</title>
      <link>https://forum.processing.org/two/discussion/25841/communicate-between-two-macs-in-processing</link>
      <pubDate>Fri, 05 Jan 2018 20:53:36 +0000</pubDate>
      <dc:creator>Faffie</dc:creator>
      <guid isPermaLink="false">25841@/two/discussions</guid>
      <description><![CDATA[<p>Hello world,
I would like to know if it is possible to communicate between two macs in processing. What I mean:</p>

<p><em>Mac1 sends a signal to mac2 -&gt; mac2 plays an audio file -&gt; mac 2 waits for another signal sent by mac1 (loop)</em></p>

<p>In the code I have written I would love to send a signal to the second mac (mac2) at "int S5_MUSIC = 5;". So that there will be two sounds played at the same time. I need the second mac for a second pair of boxes, to create a surround sound....</p>

<p><strong>This is my processing code:</strong></p>

<pre><code>import processing.serial.*;
import processing.sound.*;


int S1_WAITING_FOR_PEOPLE  = 1;
int S2_PEOPLE_ENTERED      = 2;
int S3_LIGHT_FADE_OUT      = 3;
int S4_DARK                = 4;
int S5_MUSIC               = 5;
int S6_LIGHT_FADE_IN       = 6;
// make sure this is the last!!!!
int TERMINATE              = 7;

int mode = S1_WAITING_FOR_PEOPLE;




int no_one_when_distance_greater_then = 160; // cm
int time_before_dim = 5000; // ms

SoundFile file;
boolean is_playing = false;

Serial myPort;  

int dist;

boolean someone_present = false;
int someone_present_since_time;


int music_playing_since;
int music_duration;

int in_mode_since_ms;

void setup() {
  size(640, 360);

  printArray(Serial.list()); // "/dev/cu.usbmodem1411" cu.usb!!!

  myPort = new Serial(this, Serial.list()[1], 9600);
  //myPort.readStringUntil('\n');
  myPort.bufferUntil('\n');

  // Load a soundfile from the data folder of the sketch and play it back in a loop
  file = new SoundFile(this, "Ex.wav");
  //file.loop();
  music_duration = (int) file.duration() * 1000;
  music_duration += 2000;

}      

void draw() {
  background(0);
  fill(255);
  text("frameCount: "+frameCount, 50, 25);
  text("dist: "+dist, 50, 50);
  text("mode: "+mode, 50, 75);


  if (frameCount == 180) {
    turn_on();
  } else if (frameCount &gt; 180) {

    if ( mode == S1_WAITING_FOR_PEOPLE) {

      if (someone_present == false) {
        if (dist &lt; no_one_when_distance_greater_then) {
          someone_present = true;
          someone_present_since_time = millis();
          change_mode(mode + 1);
        }
      }
    } else if (mode == S2_PEOPLE_ENTERED) {
      text("millis: "+millis(), 50, 100);
      text("someone_present_since_time: "+someone_present_since_time, 50, 125);
      text("time_before_dim: "+time_before_dim, 50, 150);
      if (millis() - someone_present_since_time &gt; time_before_dim) {
        change_mode(mode + 1);
      }
    } else if (mode == S3_LIGHT_FADE_OUT) {
      turn_off();
      change_mode(mode + 1);
    } else if (mode == S4_DARK) 
    {
      change_mode(mode + 1);
    } else if (mode == S5_MUSIC) 
    {
      if (is_playing == false) {
        file.play();
        is_playing = true;
        music_playing_since = millis();
      }
      if (millis() - music_playing_since &gt; music_duration) {
        is_playing = false;
        file.stop();
        change_mode(mode + 1);
      }
    } else if (mode == S6_LIGHT_FADE_IN) 
    {
      // todo
      if (millis() - in_mode_since_ms &gt; 1000) {
        change_mode(mode + 1);
      }

    } else if (mode == TERMINATE) 
    {
      change_mode(S1_WAITING_FOR_PEOPLE);
      someone_present = false; // reset
      println("turn_on();");
      turn_on();
    }
  }
}


void change_mode(int m) {
  mode = m;
  in_mode_since_ms = millis();
}



void serialEvent(Serial p) { 
  String s = p.readString();
  if (s != null) {
    s = s.replace("\r\n", "");
    if (s.contains("Distance Measured")) {
      String[] tokens = split(s, "=");
      dist = int(tokens[1]);
    }
  }
} 


void turn_on() {
  myPort.write("on");
}

void turn_off() {
  myPort.write("off");
}

void keyPressed() {
  if (key == 'a') {
    turn_on();
  }
  if (key == 's') {
    turn_off();
  }
}
</code></pre>

<p>Thanks for your effort.
Faffie</p>
]]></description>
   </item>
   <item>
      <title>(processing net library) code doesn't work over the internet (using public IP and port-forwarded)</title>
      <link>https://forum.processing.org/two/discussion/21177/processing-net-library-code-doesn-t-work-over-the-internet-using-public-ip-and-port-forwarded</link>
      <pubDate>Sun, 05 Mar 2017 17:24:25 +0000</pubDate>
      <dc:creator>vlames</dc:creator>
      <guid isPermaLink="false">21177@/two/discussions</guid>
      <description><![CDATA[<p>Hi everybody! I made two simple codes, one for the server and one for the client, all it does is show the value sent by the server on the screen of the client. I'm connecting trough my public IP (because I want a friend to see my value from their house), and I have forwarded my port correctly (trust me I tested it). My code works when I'm using two computers on the same network but not when someone else uses it from their house.</p>

<p>Server Code:</p>

<pre><code>  import processing.net.*;

  Server _myServer;
  int _val = 0;

  void setup() {

    _myServer = new Server(this, 25565);
  }

  void draw() {
    _val = min(255,max(0,round(map(mouseX,0,width,0,255))));
    background(0);
    text("val: " + _val,10,10);
    _myServer.write(_val);
  }
</code></pre>

<p>Client Code:</p>

<pre><code>  import processing.net.*; 

  Client _myClient; 
  int _dataIn = 0;
  String _connectIP = "213.XX.XXX.XX"; // &lt;-- my actual public IP, not Xes

  void setup() { 

    _myClient = new Client(this, _connectIP, 25565);
  } 

  void draw() {

    if (_myClient.available() &gt; 0) { 
      _dataIn = _myClient.read(); 
    } 
    background(0);
    text("dataIn: " + _dataIn,10,10);
  }
</code></pre>

<p>does anyone know why this is? am I missing something obvious? this is my first time using the net library</p>
]]></description>
   </item>
   <item>
      <title>Strange performance + Chrome Dev Tools</title>
      <link>https://forum.processing.org/two/discussion/19875/strange-performance-chrome-dev-tools</link>
      <pubDate>Wed, 21 Dec 2016 22:39:59 +0000</pubDate>
      <dc:creator>harveymoon</dc:creator>
      <guid isPermaLink="false">19875@/two/discussions</guid>
      <description><![CDATA[<p>I built a P5Js app that runs full screen on an android tablet.
When running it gets around 20fps maximum, sadly.</p>

<p>Once I connect the tablet to chrome dev tools though (over usb), I am able to get the frame rate up to 60fps for no apparent reason.
If I use the "remote devices" tool and press the "refresh" button on the chrome developer tools, It greatly speeds up the performance of the chrome tablet and P5 application. If I refresh using the native android browser button, the speeds revert back to 12-15fps.</p>

<p>Does anyone know why this is? A friend suggested that the android tablet needs it's gpu to be accelerated in order to attain those speeds and that the chrome development tools forced the GPU to activate.</p>

<p>I turned on the FPS meter and GPU rendering visualizer that appears on the tablets screen corner. 
It shows "GPU Raster - Off (Viewport)" 
When the tablet has refreshed using it's browser button I can also see how much GPU memory is being used. (48mb/256mb MAX)
When the Chrome Remote Dev Tools refreshes the page I do not see the GPU memory viewer.</p>

<p>Is it possible that Chrome Dev Tools is offloading the GPU rendering or memory onto my laptop instead and speeding up the tablet?
This would be strange because the speed improvements gained after refreshing chrome dev tools persist even after unplugging the tablet from the dev computer.</p>

<p>Does anyone know how to attain the 60FPS speeds that I am able to get while connected to dev tools?
This is a strange bug and I am not sure where to look for a solution.</p>

<p>Thanks!</p>
]]></description>
   </item>
   </channel>
</rss>